﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Web.PageUI
{
    /// <summary>
    /// 前端通用列表页
    /// </summary>
    public class BaseList : Base
    {
        public Evan.Model.SysModel.PageModels PageLists = new Evan.Model.SysModel.PageModels();
        public string SeoTitle = "";
        public string SeoKeywords = "";
        public string SeoDescription = "";
        public string keyword = string.Empty;

        public BaseList()
        {
            //Evan.SystemLog.MemLog.AddExLog2("前台排序", null, curChannelOrderBy);
            string where = string.Format(" ClassId={0} and States=1 ", ClassId);

            #region 页面搜索
            #endregion
            var temp_keyword = Evan.Common.CommFun.GetParams("tk");
            if (temp_keyword != null && !string.IsNullOrWhiteSpace(temp_keyword.Trim(' '))) 
            {

                //
                //在此可以对temp_keyword进行安全检查，剔除编程关键字等危险字符
                //
                if (!sql_inj(temp_keyword.ToLower())) { 
                 keyword = Evan.Common.CommFun.Htmls(temp_keyword);
                    where += string.Format("and (Title like '%{0}%' or Intro like '%{0}%' or Content like '%{0}%')", keyword);
                }
                
            }

            PageLists = curBLL.GetPage_2(curPageSize, curPage, where, curChannelOrderBy);
            SeoTitle = curChannel.SeoTitle;
            SeoKeywords = curChannel.SeoKeyWords;
            SeoDescription = curChannel.SeoDescription;
        }

        #region 检查危险字符

        /// <summary>

        /// 检查危险字符

        /// </summary>

        /// <param name="Input"></param>

        /// <returns></returns>



        public bool sql_inj(string str)

        {

            string inj_str = "'|and|exec|insert|select|delete|update|count|#|*|%|chr|mid|master|truncate|char|declare|;|or|-|+|,";

            string[] inj_stra = inj_str.Split('|');

            for (int i = 0; i < inj_stra.Length; i++)

            {

                if (str.IndexOf(inj_stra[i]) >= 0)

                {

                    return true;

                }

            }

            return false;

        }



        #endregion
    }
}
